<?php

	/**
	 * File : menu_bar_button.php
	 * Description : Définition et fonctions des bouton de la barre de menu
	 * Date : 07.08.2012 15:14:10
	 * 
	 * This file is part of Phenix.  Phenix is free software: you can
	 * redistribute it and/or modify it under the terms of the GNU General Public
	 * License as published by the Free Software Foundation, version 2.
	 *
	 * This program is distributed in the hope that it will be useful, but WITHOUT
	 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
	 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
	 * details.
	 *
	 * You should have received a copy of the GNU General Public License along with
	 * this program; if not, write to the Free Software Foundation, Inc., 51
	 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
	 *
	 * Nils Schaetti <n.schaetti@gmail.com>
	**/

	/*
	 * Type de bouton
	 */
	define('BUTTON_TYPE_NORMAL',1);
	define('BUTTON_TYPE_SEPARATOR',2);

	/*
	 * Représente le bouton de la barre de menu
	 */
	class ktkMenuBarButton
	{
	
		/****************************************
		 * PROPRIÉTÉS
		 ****************************************/

		/*
		 * Texte à affichier
		 */
		private $Text = '';
		
		/*
		 * Image
		 */
		private $Image;
		
		/*
		 * Type
		 */
		private $Type = BUTTON_TYPE_NORMAL;
		
		/*
		 * Lien
		 */
		private $Link = '';
		
		/**
		 * Nom du bouton
		 */
		private $Name;
		 
		/****************************************
		 * FIN PROPRIÉTÉS
		 ****************************************/
		 
		/*
		 * Constructeur
		 */
		function ktkMenuBarButton($Name, $Text, $Type, $Image, $Link)
		{
			$this->Name = $Name;
			$this->Text = $Text;
			$this->Type = $Type;
			$this->Image = $Image;
			$this->Link = $Link;
		}
	
		/**************************************
		 * FONCTIONS
		 **************************************/
		 
		function getCode()
		{
			// Code HTML
			$code = <<< __DELIMITER__
<div class="@@_TYPE_@@" id="{$this->Name}">
	<center>
		<a href="@@_LINK_@@">
			<div class="ktkIconImage" style="background-image: url('@@_IMAGE_@@');">
			</div>
		</a>
		@@_TEXT_@@
	</center>
</div>
__DELIMITER__;

			// Remplacement
			if($this->Type == BUTTON_TYPE_NORMAL)
				$code = str_replace('@@_TYPE_@@', 'ktkIcon', $code);
			else
				$code = str_replace('@@_TYPE_@@', 'ktkIconSeparator', $code);
			$code = str_replace('@@_TEXT_@@', $this->Text, $code);
			$code = str_replace('@@_LINK_@@', $this->Link, $code);
			$code = str_replace('@@_IMAGE_@@', $this->Image, $code);

			// Retourne le code
			return $code;
		}
		 
		 /****************************************
		 * FIN DE FONCTIONS
		 ****************************************/
	
	}

?>
